import * as moment from 'moment';
import { ValueTransformer } from 'typeorm';

const dateTransformer: ValueTransformer = {
  // 读取
  from(value: any): any {
    return moment(value).format('YYYY-MM-DD HH:mm:ss');
  },
  // 写到数据库
  to(value: any): any {
    return value;
  },
};

export default dateTransformer;
